package com.sky.controller.admin;

import com.sky.dto.DishPageQueryDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.SetMealService;
import com.sky.vo.SetmealVO;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("adminSeatMealController")
@RequestMapping("/admin/setmeal")
@Api(tags = "套餐相关")
@Slf4j
public class SetMealController {

    @Autowired
    private SetMealService setMealService;

    /**
     * 套餐数据的分页查询
     * @param setmealPageQueryDTO
     * @return
     */
    @GetMapping("page")
    public Result<PageResult> page(SetmealPageQueryDTO setmealPageQueryDTO){
        log.info("套餐的分页查询来了");
        PageResult pageResult =setMealService.pageQuery(setmealPageQueryDTO);
        return Result.success(pageResult);
    }

    /**
     * 数据查询回显
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Result<SetmealVO> ShowSetMealById(@PathVariable(value = "id") Long id){
        SetmealVO setmeal = setMealService.getById(id);
        return Result.success(setmeal);
    }

    /**
     * 切换状态
     * @param status
     * @param id
     * @return
     */
    @PostMapping("/status/{status}")
    public Result changeDishStatus(@PathVariable Integer status ,@RequestParam(value = "id")Integer id) {
        log.info("切换菜品id={}的状态：",id);
        setMealService.changeDishStatus(status,id);
        return Result.success();
    }


}
